<?php
$q=$_GET["q"];
		$TABLE1 = "Parts";
        $TABLE2 = "Parts_Required";
        $TABLE3 = "Finished_Goods";
        $ROW_NUMBER = 0;
        $PASS = "";
        $USER = "root";
        $HOST = "localhost";
        $CON = mysql_connect( $HOST, $USER, $PASS );
        $DB = "softengtestdatabase";
        if (!$CON)
          {
                  die('Could not connect: ' . mysql_error());
          }

        mysql_select_db( $DB );
        $QRY = "SELECT Parts.part_id, Finished_Goods.fg_id, Parts.cost, Parts.part_description FROM Parts, Parts_Required, Finished_Goods WHERE Parts.part_id = Parts_Required.part_id AND Parts_Required.fg_id = Finished_Goods.fg_id AND Finished_Goods.fg_id ='".$q."'";

        $result = mysql_query($QRY) or die($QRY."<br/><br/>".mysql_error());



	echo '<table style="width: 100%; border: 5px #aba groove;">';
        echo '<tr style="background-color: #D6B376;"><th style="text-align: center;">PartID</th><th style="text-align: center;">FG ID</th><th style="text-align: center;">Cost</th><th style="text-align: center;">Description</th></tr>';

while($ROW = mysql_fetch_array($result))
        {
                echo '<tr style="background-color: #';
                if ( $ROW_NUMBER % 2 ){ echo 'FFF;"'; }
                else { echo 'DEDEDE;"'; }

                echo '><td style="padding-left: 5px;">' . $ROW['part_id'] . '</td><td>' . $ROW['fg_id'] . '</td><td style="text-align: right;">$' . $ROW['cost'] .  '</td><td style="text-align: right;">' . $ROW['part_description'] . '</td></tr>';
        if ( $ROW_NUMBER % 50 == 0 && $ROW_NUMBER != 0 )
        {
                 echo '<tr style="background-color: #D6B376;"><th style="text-align: center;">Part ID</th><th style="text-align: center; width: 75px;">FG ID</th><th style="width: 75px; text-align: center;">Cost</th><th style="text-align: center;">Description</th></tr>';
        }
        $ROW_NUMBER++;
        }
        mysql_close($CON);
        echo '</table>';
?>




